#include <stdio.h>
#include <string.h>
#include "fs.h"
#include "mysql_util.h"
#define MAX 20

/* pcm */
void record_water(struct water wr){
    printf("录入用水数据\n");
    int bool_in_temp = 1;
    do{
        printf("请输入水量记录时间:\n");
        scanf("%s", wr.record_time);
        printf("请输入用水量:\n");
        scanf("%lf", &wr.amount);
        printf("请输入水费单价:\n");
        scanf("%lf", &wr.price);
        wr.fee = wr.amount * wr.price;
        /* INTERFACE write record_time amount price fee into database  */
		sql_record_water(wr);
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}
void show_water(struct water wr){
    printf("查询用水数据\n");
    int bool_in_temp = 1;
    do{
        printf("请输入查询用水量记录时间(xxxx-xx-xx):\n:");
        scanf("%s", wr.record_time );
        
        bool bool_id;// INTERFACE return if the id in sql database or not
        bool_id = sql_show_water(wr);
        if(bool_id){
            /* Show information of water */
            printf("用水量记录时间输入正确!\n");
            /* INTERFACE read record_time amount price fee from database */
            printf("用水量记录时间:%s\n", wr.record_time);
            printf("用水量:%lf\n", wr.amount);
            printf("水费单价:%lf\n", wr.price);
            printf("水费总费用:%lf\n", wr.fee);
        }else{
            printf("用水量记录时间输入错误!\n");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void record_electricity(struct electricity elty){
    printf("录入用电数据\n");
    int bool_in_temp = 1;
    do{
        printf("请输入电量记录时间:\n");
        scanf("%s", elty.record_time);
        printf("请输入用电量:\n");
        scanf("%lf", &elty.amount);
        printf("请输入电费单价:\n");
        scanf("%lf", &elty.price);
        elty.fee = elty.amount * elty.price;
		sql_record_electricity(elty);
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}
void show_electricity(struct electricity elty){
    printf("查询用电数据\n");
    int bool_in_temp = 1;
    do{
        printf("请输入查询用电量记录时间(xxxx-xx-xx):\n:");
        scanf("%s", elty.record_time );
        bool bool_id = sql_show_electricity(elty);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of water */
            printf("用电量记录时间输入正确!\n");
            /* INTERFACE read record_time amount price fee from database */
            printf("用电量记录时间:%s\n", elty.record_time);
            printf("用电量:%lf\n", elty.amount);
            printf("电费单价:%lf\n", elty.price);
            printf("电费总费用:%lf\n", elty.fee);
        }else{
            printf("用电量记录时间输入错误!\n");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}
void production_cost_manager(){
    struct water wr;
    struct electricity elty;
    printf("欢迎进入生产费用管理!\n");
    printf("请选择您要进入的功能编号\n");
    printf("1.水费管理\n");
    printf("2.电费管理\n");
    printf("0.返回上一层\n");
    printf("请输入您的选择：");
    int pcm_choice;
    while(1){
    	scanf("%d",&pcm_choice);
        if(pcm_choice == 1){
        	//水费管理
            printf("欢迎进入水费管理!\n");
            printf("请选择您要进入的功能编号\n");
            printf("1.水费登记\n");
            printf("2.水费查询\n");
            printf("0.返回上一层\n");
            printf("请输入您的选择：");
            int wr_choice;
            while(1){
                scanf("%d",&wr_choice);
                if(wr_choice == 1){
                    //水费登记
                    printf("\n");
                    record_water(wr);
                    continue;
                }
                else if(wr_choice == 2){
                    //水费查询
                    printf("\n");
                    show_water(wr);
                    continue;
                }
                else if(wr_choice == 0){
        	        //退出模块
        	        break;
		        }
                else{
                    printf("错误编号！请重新输入：");
                    continue; 
                }
            }
        	continue;
		}
		else if(pcm_choice == 2){
			//电费管理
            printf("欢迎进入电费管理!\n");
            printf("请选择您要进入的功能编号\n");
            printf("1.电费登记\n");
            printf("2.电费查询\n");
            printf("0.返回上一层\n");
            printf("请输入您的选择：");
            int elty_choice;
            while(1){
                scanf("%d",&elty_choice);
                if(elty_choice == 1){
                    //电费登记
                    printf("\n");
                    record_electricity(elty);
                    continue;
                }
                else if(elty_choice == 2){
                    //电费查询
                    printf("\n");
                    show_electricity(elty);
                    continue;
                }
                if(elty_choice == 0){
        	        //退出模块
        	        continue;
		        }
                else{
                    printf("错误编号！请重新输入：");
                    continue; 
                }
            }
			continue;
		}
        else if(pcm_choice == 0){
            break;
        }
		else{
			printf("错误编号！请重新输入：");
			continue; 
		}
    }
}
/* pcm */

/* osm */
void desk_register(struct desk dk){
    printf("登记桌子\n");
    int bool_in_temp = 1;
    do{
        printf("请输入桌子ID:\n");
        scanf("%s", dk.id);
        printf("请输入桌子型号:\n");
        scanf("%s", dk.model);
        printf("请输入桌子价格:\n");
        scanf("%lf", &dk.price);
        printf("请输入桌子登记日期,xxxx-xx-xx!");
        scanf("%s", dk.register_time);
		sql_desk_register(dk);
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}
void desk_recycle(struct desk dk){
    printf("回收桌子\n");
    int bool_in_temp = 1;
    do{
        printf("请输入桌子ID:\n");
        scanf("%s", dk.id );
        bool bool_id = sql_show_desk(dk);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of a id */
            printf("桌子ID输入正确!\n");
            printf("请输入桌子回收时间:\n");
            scanf("%s",dk.recycle_time);
            printf("请输入桌子回收价格:\n");
            scanf("%lf",&dk.recycle_price);
            dk.state = 0;//INTERFACE write state into database
            sql_desk_recycle(dk);
        }else{
            printf("桌子ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void show_desk(struct desk dk){
    printf("查询椅子\n");
    int bool_in_temp = 1;
    do{
        printf("请输入桌子ID:\n");
        scanf("%s", dk.id );
        bool bool_id = sql_show_desk(dk);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of a id */
            printf("桌子ID输入正确!\n");
            printf("桌子ID:%s!\n", dk.id);
            printf("桌子型号:%s\n", dk.model);//INTERFACE return model from database
            printf("桌子价格:%lf\n", dk.price);//INTERFACE return price from database
            printf("桌子登记日期:%s\n", dk.register_time);//INTERFACE return register_time from database
            if(dk.state == 1){
                printf("桌子使用状态:使用中\n"); 
            }else if(dk.state == 0){
                printf("桌子使用状态:已回收\n");
                printf("桌子回收价格:%lf\n", dk.recycle_price);// INTERFACE return recycle_price from database
                printf("桌子回收日期:%s\n", dk.recycle_time);
            }
        }else{
            printf("桌子ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n"); 
}

void chair_register(struct chair cr){
    printf("登记椅子\n");
    int bool_in_temp = 1;
    do{
        printf("请输入椅子ID:\n");
        scanf("%s", cr.id);
        printf("请输入椅子型号:\n");
        scanf("%s", cr.model);
        printf("请输入椅子价格:\n");
        scanf("%lf", &cr.price);
        printf("请输入椅子登记日期,xxxx-xx-xx!");
        scanf("%s", cr.register_time);
        sql_chair_register(cr);
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n"); 
}
void chair_recycle(struct chair cr){
    printf("回收椅子\n");
    int bool_in_temp = 1;
    do{
        printf("请输入椅子ID:\n");
        scanf("%s", cr.id );
        bool bool_id = sql_show_chair(cr);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of a id */
            printf("椅子ID输入正确!\n");
            printf("请输入椅子回收时间:\n");
            scanf("%s",cr.recycle_time);
            printf("请输入椅子回收价格:\n");
            scanf("%lf",&cr.recycle_price);
            //printf("INTERFACE write data into database!\n");
            cr.state = 0;//INTERFACE write state into database
            sql_chair_recycle(cr);
        }else{
            printf("椅子ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void show_chair(struct chair cr){
    printf("查询椅子\n");
    int bool_in_temp = 1;
    do{
        printf("请输入椅子ID:\n");
        scanf("%s", cr.id );
        bool bool_id = sql_show_chair(cr);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of chair */
            printf("椅子ID输入正确!\n");
			printf("椅子ID:%s!\n", cr.id);
            printf("椅子型号:%s\n", cr.model);//INTERFACE return model from database
            printf("椅子价格:%lf\n", cr.price);//INTERFACE return price from database
            printf("椅子登记日期:%s\n", cr.register_time);//INTERFACE return register_time from database
            if(cr.state == 1){
                printf("椅子使用状态:使用中\n"); 
            }else if(cr.state == 0){
                printf("椅子使用状态:已回收\n");
                printf("椅子回收价格:%lf\n", cr.recycle_price);// INTERFACE return recycle_price from database
                printf("椅子回收日期:%s\n", cr.recycle_time);
            }
        }else{
            printf("椅子ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void office_supplies_manager(){
    struct desk dk;
    struct chair cr;
    printf("欢迎进入办公用品管理模块!\n");
    printf("请选择您要进入的功能编号\n");
    printf("1.桌子管理\n");
    printf("2.椅子管理\n");
    printf("0.返回上一层\n");
    printf("请输入您的选择：");
    int osm_choice;
    while(1){
    	scanf("%d",&osm_choice);
        if(osm_choice == 1){
        	//桌子管理
            printf("欢迎进入桌子管理!\n");
            printf("请选择您要进入的功能编号\n");
            printf("1.桌子登记\n");
            printf("2.桌子查询\n");
            printf("3.桌子回收\n");
            printf("0.返回上一层\n");
            printf("请输入您的选择：");
            int dk_choice;
            while(1){
                scanf("%d",&dk_choice);
                if(dk_choice == 1){
                    //桌子登记
                    printf("\n");
                    desk_register(dk);
                    continue;
                }
                else if(dk_choice == 2){
                    //桌子查询
                    printf("\n");
                    show_desk(dk);
                    continue;
                }
                else if(dk_choice == 3){
                    //桌子回收
                    printf("\n");
                    desk_recycle(dk);
                    continue;
                }
                if(dk_choice == 0){
        	        //退出模块
        	        break;
		        }
                else{
                    printf("错误编号！请重新输入：");
                    continue; 
                }
            }
        	continue;
		}
		else if(osm_choice == 2){
			//椅子管理
            printf("欢迎进入椅子管理!\n");
            printf("请选择您要进入的功能编号\n");
            printf("1.椅子登记\n");
            printf("2.椅子查询\n");
            printf("3.椅子回收\n");
            printf("0.返回上一层\n");
            printf("请输入您的选择：");
            int cr_choice;
            while(1){
                scanf("%d",&cr_choice);
                if(cr_choice == 1){
                    //打椅子登记
                    printf("\n");
                    chair_register(cr);
                    continue;
                }
                else if(cr_choice == 2){
                    //椅子查询
                    printf("\n");
                    show_chair(cr);
                    continue;
                }
                else if(cr_choice == 3){
                    //椅子回收
                    printf("\n");
                    chair_recycle(cr);
                    continue;
                }
                if(cr_choice == 0){
        	        //退出模块
        	        break;
		        }
                else{
                    getchar();
                    printf("错误编号！请重新输入：");
                    continue; 
                }
            }
			continue;
		}
        else if(osm_choice == 0){
            break;
        }
		else{
			printf("错误编号！请重新输入：");
			continue; 
		}
    }
}
/* osm */


/* edm */
void computer_register(struct computer cmpr){
    printf("登记电脑\n");
    /* Register computer id et.al */
    int bool_in_temp = 1;
    do{
        printf("请输入电脑ID:\n");
        scanf("%s", cmpr.id);
        printf("请输入电脑型号:\n");
        scanf("%s", cmpr.model);
        printf("请输入电脑价格:\n");
        scanf("%lf", &cmpr.price);
        printf("请输入电脑登记日期,xxxx-xx-xx!");
        scanf("%s", cmpr.register_time);
        sql_computer_register(cmpr);
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void computer_recycle(struct computer cmpr){
    printf("回收电脑\n");
    int bool_in_temp = 1;
    do{
        printf("请输入电脑ID:\n");
        scanf("%s", cmpr.id );
        bool bool_id = sql_show_computer(cmpr);;// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of a id */
            printf("电脑ID输入正确!\n");
            printf("请输入电脑回收时间:\n");
            scanf("%s",cmpr.recycle_time);
            printf("请输入电脑回收价格:\n");
            scanf("%lf",&cmpr.recycle_price);
            cmpr.state = 0;//INTERFACE write state into database
            sql_computer_recycle(cmpr);
        }else{
            printf("电脑ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void show_computer(struct computer cmpr){
    printf("查询电脑\n");
    int bool_in_temp = 1;
    do{
        printf("请输入电脑ID:\n");
        scanf("%s", cmpr.id );
        bool bool_id = sql_show_computer(cmpr);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of a id */
            printf("电脑ID输入正确!\n");
			printf("电脑ID:%s!\n", cmpr.id);
            printf("电脑型号:%s\n", cmpr.model);//INTERFACE return model from database
            printf("电脑价格:%lf\n", cmpr.price);//INTERFACE return price from database
            printf("电脑登记日期:%s\n", cmpr.register_time);//INTERFACE return register_time from database
            if(cmpr.state == 1){
                printf("电脑使用状态:使用中\n"); 
            }else if(cmpr.state == 0){
                printf("电脑使用状态:已回收\n");
                printf("电脑回收价格:%lf\n", cmpr.recycle_price);// INTERFACE return recycle_price from database
                printf("电脑回收日期:%s\n", cmpr.recycle_time);
            }
        }else{
            printf("电脑ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void printer_register(struct printer pinr){
    printf("登记打印机\n");
    /* Register printer id et.al */
    int bool_in_temp = 1;
    do{
        printf("请输入打印机ID:\n");
        scanf("%s", pinr.id);
        printf("请输入打印机型号:\n");
        scanf("%s", pinr.model);
        printf("请输入打印机价格:\n");
        scanf("%lf", &pinr.price);
        printf("请输入打印机登记日期,xxxx-xx-xx!");
        scanf("%s", pinr.register_time);
        sql_printer_register(pinr);
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void printer_recycle(struct printer pinr){
    printf("回收打印机\n");
    int bool_in_temp = 1;
    do{
        printf("请输入打印机ID:\n");
        scanf("%s", pinr.id );
        bool bool_id = sql_show_printer(pinr);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of a id */
            printf("打印机ID输入正确!\n");
            printf("请输入打印机回收时间:\n");
            scanf("%s",pinr.recycle_time);
            printf("请输入打印机回收价格:\n");
            scanf("%lf", &pinr.recycle_price);
            pinr.state = 0;
            sql_printer_recycle(pinr);
        }else{
            printf("打印机ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void show_printer(struct printer pinr){
    printf("查询打印机\n");
    int bool_in_temp = 1;
    do{
        printf("请输入打印机ID:\n");
        scanf("%s", pinr.id );
        bool bool_id = sql_show_printer(pinr);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show information of a id */
            printf("ID输入正确!\n");
			printf("打印机ID:%s\n", pinr.id);
            printf("打印机型号:%s\n", pinr.model);//INTERFACE return model from database
            printf("打印机价格:%lf\n", pinr.price);//INTERFACE return price from database
            printf("打印机登记日期:%s\n", pinr.register_time);//INTERFACE return register_time from database
            if(pinr.state == 1){
                printf("打印机使用状态:使用中\n"); 
            }else if(pinr.state == 0){
                printf("打印机使用状态:已回收\n");
                printf("打印机回收价格:%lf\n", pinr.recycle_price);// INTERFACE return recycle_price from database
                printf("打印机回收日期:%s\n", pinr.recycle_time);
            }
        }else{
            printf("打印机ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void electronic_devices_manager(){
    struct computer cmpr;
    struct printer pinr;
    printf("欢迎进入电子设备管理模块!\n");
    printf("请选择您要进入的功能编号\n");
    printf("1.电脑管理\n");
    printf("2.打印机管理\n");
    printf("0.返回上一层\n");
    printf("请输入您的选择：");
    int choice;
    while(1){
    	scanf("%d",&choice);
        if(choice == 1){
        	//电脑管理
            printf("\n");
            printf("欢迎进入电脑管理!\n");
            printf("请选择您要进入的功能编号\n");
            printf("1.电脑登记\n");
            printf("2.电脑查询\n");
            printf("3.电脑回收\n");
            printf("0.返回上一层\n");
            printf("请输入您的选择：");
            int choice;
            while(1){
                scanf("%d",&choice);
                if(choice == 1){
                    //电脑登记
                    printf("\n");
                    computer_register(cmpr);
                    continue;
                }
                else if(choice == 2){
                    //电脑查询
                    printf("\n");
                    show_computer(cmpr);
                    continue;
                    // break;
                }
                else if(choice == 3){
                    //电脑回收
                    printf("\n");
                    computer_recycle(cmpr);
                    continue;
                }
                if(choice == 0){
        	        //退出模块
        	        break;
		        }
                else{
                    printf("错误编号！请重新输入：");
                    continue; 
                }
            }
            printf("\n");
        	continue;
		}
		else if(choice == 2){
			//打印机管理
            printf("\n");
            printf("欢迎进入打印机管理!\n");
            printf("请选择您要进入的功能编号\n");
            printf("1.打印机登记\n");
            printf("2.打印机查询\n");
            printf("3.打印机回收\n");
            printf("0.返回上一层\n");
            printf("请输入您的选择：");
            int choice;
            while(1){
                scanf("%d",&choice);
                if(choice == 1){
                    //打印机登记
                    printf("\n");
                    printer_register(pinr);
                    continue;
                }
                else if(choice == 2){
                    //打印机查询
                    printf("\n");
                    show_printer(pinr);
                    continue;
                }
                else if(choice == 3){
                    //打印机回收
                    printf("\n");
                    printer_recycle(pinr);
                    continue;
                }
                if(choice == 0){
        	        //退出模块
        	        break;
		        }
                else{
                    printf("错误编号！请重新输入：");
                    continue; 
                }
            }
            printf("\n");
			continue;
		}
        else if(choice == 0)
        {
            break;
        }
		else{
			printf("错误编号！请重新输入：");
			continue; 
		}
    }
}
/* edm */

/* fam */
void fixed_assets_manager(){
    printf("欢迎进入固定资产管理模块!\n");
    printf("请选择您要进入的功能编号\n");
    printf("1.电子设备管理\n");
    printf("2.办公用品管理\n");
    printf("3.生产费用管理\n");
    printf("0.返回上一层\n");
    printf("请输入您的选择：");
    int choice;
    while(1){
    	scanf("%d",&choice);
        if(choice == 1){
        	//电子设备管理
            printf("\n");
            electronic_devices_manager();
        	continue;
		}
		else if(choice == 2){
			//办公用品管理
            printf("\n");
            office_supplies_manager();
			continue;
		}
        else if(choice == 3){
			//生产费用管理
            printf("\n");
            production_cost_manager();
			continue;
		}
        if(choice == 0){
        	//退出模块
        	break;
		}
		else{
			printf("错误编号！请重新输入：");
			continue; 
		}
    }
    printf("\n");
}
/* fam */

/* ssm */
void input_minimum_fixed(struct salary &slry){
    /* Default for minimum and fixed */
    printf("请输入最低工资(人民币/元):\n");
    scanf("%lf", &slry.minimum);
    printf("请输入固定工资(人民币/元):\n");
    scanf("%lf", &slry.fixed);
	sql_input_minimum_fixed(slry);
    printf("\n");
}

/* Input bonus */
void input_bonus(struct salary &slry){
    printf("录入员工奖金\n");
    int bool_in_temp = 1;
    do{
        printf("请输入员工ID:\n");
        scanf("%s", slry.unsy.id );
        printf("请输入奖金的年月日(xxxx-xx-xx)!");
        scanf("%s", slry.unsy.ymd);
        char sql_ymd[100];
        strcpy(sql_ymd, slry.unsy.ymd);// INTERFACE write year_month_day into sql database
        /* Write bonus into database  */
        printf("请输入奖金金额!\n");
        scanf("%lf", &slry.unsy.bonus);
        sql_input_bonus(slry);
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

/* Unfixed change is finished by STAFF MANGER GROUP to change the total */
/* NO OPERATION FOR FSS SYSTEM */

/* Input Performance id time data from PROJECT GROUP*/
void get_performance(struct salary &slry){
    /* Performance return from PROJECT GROUP */
    printf("请输入员工ID:\n");
    // char project_name[100];
    scanf("%s", slry.unsy.id);
    printf("请输入绩效登记的时间(年月日):\n");
    // char ymd_temp[100];
    scanf("%s", slry.unsy.ymd);
    //INTERFACE 需要从数据库拿到该员工ID对应结构体struct Project_member pm数据,目的是获取该结构体的:work_id 和 worker_earnings数据
    //query_project_member(slry.unsy.id, Project_member& s)

    //wz add 
    // float p;
    // sql_get_performance(slry.unsy.ymd, p);
    // slry.unsy.performance = p;

    double PROJECT_GROUP_RETRUN_PERFORMANCE = 2000.00;// = pm.worker_earinings
    // char PROJECT_GROUP_RETURN_ID[100];// =pm.work_id
    slry.unsy.performance = PROJECT_GROUP_RETRUN_PERFORMANCE;
    
    sql_get_performance(slry);
    printf("获取员工绩效工资完成!\n");
    /* INTERFACE write performance into database */
}

void compu_salary(struct salary slry){
    slry.unsy.total = slry.fixed + slry.unsy.bonus;
    /* INTERFACE write total into databas */
	sql_compu_salary(slry);
    
}
void compu_salary_performance(struct salary &slry){
    sql_get_bonus_fixed_min(slry);
    printf("员工ID:%s\n",slry.unsy.id);
    printf("最低工资:%lf\n", slry.minimum);
    printf("固定工资:%lf\n", slry.fixed);
    printf("奖金:%lf\n", slry.unsy.bonus);
    printf("津贴:%lf\n", slry.unsy.performance);
    
    slry.unsy.total = slry.minimum + slry.fixed + slry.unsy.bonus+ slry.unsy.performance;
    printf("月总薪资:%lf\n", slry.unsy.total);
    /* INTERFACE write total into databas */
    sql_compu_salary(slry);
}

/* Show salary of a id */
void show_salary(struct salary slry){
    printf("查询员工薪资\n");
    int bool_in_temp = 1;
    do{
        printf("请输入员工ID:\n");
        scanf("%s", slry.unsy.id );
        printf("请输入查询时间:\n");
        scanf("%s", slry.unsy.ymd);
        bool bool_id = sql_show_salary(slry);// INTERFACE return if the id in sql database or not
        if(bool_id){
            /* Show salary of a id */
            printf("员工ID输入正确!\n");
            printf("员工%s的%s月的总薪资为%lf元\n", slry.unsy.id,slry.unsy.ymd ,slry.unsy.total);//INTERFACE return total et.al from database 
        }else{
            printf("员工ID输入错误!");
        }
        /* Continue input or not */
        char bool_in[100];
        printf("继续请输入y/退出请输入其它任意键):");
        scanf("%s", bool_in );
        bool_in_temp = strcmp(bool_in, "y");
    }while(bool_in_temp == 0);
    printf("\n");
}

void staff_salary_manager(){
    struct salary slry;
    printf("欢迎进入员工薪资管理模块!\n");
    printf("请选择您要进入的功能编号\n");
    printf("1.输入固定薪资和最低薪资\n");
    printf("2.输入员工奖金\n");
    // printf("3.获取员工绩效\n");
    printf("3.计算员工月薪资\n");
    printf("4.查询员工月薪资\n");
    printf("0.返回上一层\n");
    printf("请输入您的选择：");
    int ssm_choice;
    while(1){
    	scanf("%d",&ssm_choice);
        if(ssm_choice == 1){
        	//输入固定薪资和最低薪资和基本薪资
            printf("\n");
            input_minimum_fixed(slry);
            continue;
		}
		else if(ssm_choice == 2){
			//输入员工奖金
            printf("\n");
            input_bonus(slry);
            continue;
		}
        else if(ssm_choice == 3){
			//计算员工月薪资
            printf("\n");
            printf("计算员工月薪资\n");
            get_performance(slry);//获取绩效

            compu_salary_performance(slry);
            printf("员工%s,日期%s的薪资计算完成!\n", slry.unsy.id, slry.unsy.ymd);
            printf("\n");
            // show_salary(slry);
            continue;
		}
        else if(ssm_choice == 4){
			//查询员工月薪资
            printf("\n");
            show_salary(slry);
            continue;
		}
        else if(ssm_choice == 0){
        	//退出模块
        	break;
		}
		else{
			printf("错误编号！请重新输入：");
			continue; 
		}
    }
    printf("\n");
}
/* ssm */

/* fss */
void finance_system_start(){
    printf("欢迎进入财务系统!\n");
    printf("请选择您要进入的系统编号\n");
    printf("1.员工薪资管理模块\n");
    printf("2.固定资产管理模块\n");
    printf("0.退出系统\n");
    printf("请输入您的选择：");
    int fss_choice;
    while(1){
    	scanf("%d",&fss_choice);
        if(fss_choice == 1){
        	//员工薪资管理模块
            printf("\n");
            staff_salary_manager();
            continue;

		}
		else if(fss_choice == 2){
			//固定资产管理模块
            printf("\n");
            fixed_assets_manager();
            continue;
		}
        else if(fss_choice == 0){
            break;
        }
		else{
			printf("错误编号！请重新输入：");
			continue; 
		}
    }
}
/* fss */

// int main() {
//     initialize();
//     finance_system_start();
//     closeDB();
//     return 0;
// }